Skip to content

fix(settings): start watchdog on cold-enable from the React UI (#9125) - #10287

Merged
mudler merged 1 commit into
masterfrom
fix/9125-watchdog-cold-enable
Jun 14, 2026
Merged

fix(settings): start watchdog on cold-enable from the React UI (#9125)#10287
mudler merged 1 commit into
masterfrom
fix/9125-watchdog-cold-enable

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

Re: #9125

The original v4.0.0 "settings don't save" report is already resolved (settings persist to runtime_settings.json across reload + restart). This fixes a residual bug found while verifying: enabling the watchdog from a cold (off) state via the React Settings master toggle did nothing until the next server restart.

Root cause

UpdateSettingsEndpoint (core/http/endpoints/localai/settings.go:226) keyed its live start/stop decision off the raw request field watchdog_enabled. The React master toggle only writes watchdog_idle_enabled/watchdog_busy_enabled; watchdog_enabled is vestigial and loads stale as false. So a cold-enable POST carried watchdog_enabled=false, the handler called StopWatchdog() (a no-op), and the watchdog never started until restart re-derived it from the idle flag.

Fix

  • ApplyRuntimeSettings now derives o.WatchDog = idle || busy whenever either field is present (also fixes the disable direction).
  • New WatchdogShouldRun() mirrors startWatchdog's gating; the settings handler uses it instead of the raw watchdog_enabled.
  • Belt-and-suspenders: the React master toggle also writes watchdog_enabled = idle||busy.

Test plan

  • core/config/application_config_test.go: cold-enable, disable-both, and explicit-watchdog_enabled backward-compat specs.
  • core/http/endpoints/localai/settings_test.go: HTTP spec asserting the live watchdog is non-nil after a cold-enable POST (red → green).
  • go test ./core/config/... ./core/http/endpoints/localai/... green; scoped lint clean.

Assisted-by: claude:claude-opus-4-8 [Claude Code]

…#9125)

The React Settings "Enable Watchdog" master toggle only ever writes the
idle/busy flags; watchdog_enabled is vestigial in that UI. The live
start/stop decision in UpdateSettingsEndpoint keyed off the raw, stale
watchdog_enabled request field, so a cold enable (idle/busy=true,
watchdog_enabled=false) called StopWatchdog() and the watchdog stayed
stopped until the next restart - at which point startup re-derived it
from the idle flag. Net: enabling the watchdog appeared to do nothing.

Derive the run-state from idle||busy as the single source of truth,
mirroring the startup invariant:

- ApplyRuntimeSettings now sets WatchDog = idle||busy whenever either
  field is present (so a full disable also brings it down), while an API
  client posting only watchdog_enabled keeps its explicit value.
- Add ApplicationConfig.WatchdogShouldRun() mirroring startWatchdog's
  gating (idle/busy, LRU eviction, memory reclaimer); the /api/settings
  handler uses it to decide start vs stop.
- Belt-and-suspenders: the Settings.jsx master toggle also writes
  watchdog_enabled = idle||busy.

Assisted-by: claude:claude-opus-4-8 [Claude Code]
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
@mudler
mudler merged commit fdc352a into master Jun 14, 2026
60 checks passed
@mudler
mudler deleted the fix/9125-watchdog-cold-enable branch June 14, 2026 14:46
@localai-bot localai-bot added the bug Something isn't working label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants